<template>
	<view>
		<u--text text="选好奶茶店再选" size=25></u--text>
		<!-- <uni-data-select v-model="value" :localdata="range" @change="change"></uni-data-select> -->
		

		<!-- <button class="btn_margin" type="primary" @click="start">开始</button>
		<button class="btn_margin" type="primary" @click="over">停止</button> -->
	</view>
</template>

<script>
	export default {
		data() {
			return {
				show: false,
				columns: [
					['中国', '美国', '日本']
				],
				value: 0,
				range: [{
						value: 0,
						text: "蜜雪冰城",
						mean: ["柠檬水", "冰淇淋", "杨枝甘露", "四季春奶盖", "绿茶", "红茶", "四季春", "芋泥奶茶"]
					},
					{
						value: 1,
						text: "茶白道",
						mean: ["柠檬水", "麻薯", "酸奶", "绿茶", "芋圆奶茶", "桂花酒酿", "杨枝甘露", "烧仙草", "紫薯酸奶"]
					},
					{
						value: 2,
						text: "古茗",
						mean: ["柠檬水", "珍珠奶茶", "青柠红茶", "芝士青提", "布丁西米露", "栀子青", "龙井香牛乳茶"]
					},
					{
						value: 3,
						text: "益禾堂",
						mean: ["柠檬水", "奶绿", "椰奶", "芋泥啵啵", "红茶烤奶", "香芋奶茶", "金桔柠檬", "牛奶烧仙草"]
					},
				],
				drings: '柠檬水',
				store: '蜜雪冰城',
				timer: null,
				timerValue: 0,
				selectValue: null,
			}
		},
		methods: {
			confirm(e) {
				console.log(e);
			},

			change(e) {
				this.selectValue = e;
				if (e == 0) {
					this.store = this.range[e].text
					// this.drings = this.range[e].mean[e]
					const result = this.range[e].mean[Math.floor(Math.random() * (this.range[e].mean.length))];
					console.log("今天点", this.store, "的", result);
				} else {
					this.store = this.range[e].text
					//用户点的菜单里的索引值  
					const result = this.range[e].mean[Math.floor(Math.random() * (this.range[e].mean.length))];
					// .length))]; //获取菜单里随机抽取的值
					// this.drings = this.range[e].mean[Math.floor(Math.random() * (this.range[e].mean.length))]
					console.log("今天点", this.store, "的", result);
					// console.log("下拉框的值",this.selectValue);

				}
			},

			start() {
				if (this.timer != null) {
					clearInterval(this.timer);
				}
				this.timer = setInterval(this.choose, 100);
				console.log("开始随机选喝什么")

			},
			choose(e) {
				e = this.selectValue;
				this.timerValue++;
				const meanOrder = this.range[this.range[e].value].mean;
				this.drings = meanOrder[Math.floor(Math.random() * (meanOrder.length))]
				// console.log("随机选取",this.drings)

			},

			over() {
				clearInterval(this.timer);
				this.timer = null;
				console.log("点这个")
			},



		},
		onLoad: function(option) {
			//跳转页面接收参数
			console.log(option);
		},
		beforeDestroy() {
			clearTimeout(this.timer);
		},

	}
</script>

<style>

</style>